package com.fr.kak;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 付荣
 * @version 创建时间：2018年1月31日 下午4:46:01
 */
public class ServiceAnalyzer {

	public static void main(String[] args) throws Exception {
		File file = new File("E:\\AutoCompleteNewService.txt");
		FileReader fr = new FileReader(file);
		BufferedReader br = new BufferedReader(fr);
		String line = null;
		Map<String, Map<String,Integer>> result = new HashMap<>();
		while((line = br.readLine()) != null){
			String [] aggr = line.split("\t");
			if(aggr.length < 4){
				continue;
			}
			Map<String,Integer> map = result.get(aggr[2]);
			if(map == null){
				map = new HashMap<>();
				result.put(aggr[2], map);
			}else{
				Integer count = map.get(aggr[0]);
				if(count == null){
					count = Integer.parseInt(aggr[3]);
				}else{
					count += Integer.parseInt(aggr[3]);
				}
				map.put(aggr[0], count);
			}
		}
		br.close();
		fr.close();
		for(Map.Entry<String, Map<String,Integer>> e: result.entrySet()){
			System.out.println(e.getKey());
			for(Map.Entry<String, Integer> e1 : e.getValue().entrySet()){
				System.out.println(e1.getKey() +"\t"+ e1.getValue());
			}
		}
	}
}
